03. Pricing Service Code
Pricing Service Code
You'll find the code related to our oricing service in the pricing-service
folder. It serves as a REST WebService that simulates a backend to store and retrieve the price of a given vehicle. In the project, you will convert it to be a microservice registered through a Eureka server.
Let's take a quick look through the included files, only certain files of which you will need to implement. Note that every package is within com.udacity
, so we won't include that part of the package name below.
pricing
PricingServiceApplication
This launches the Pricing Service as a Spring Boot application.
pricing.api
PricingController
This is our actual REST controller for the application. This implements what a GET request will respond with - in this case, a randomly generated price gathered from the PricingService
. Once converted to a microservice, the Controller should not be explicitly necessary.
pricing.domain.price
Price
This declares the Price class, primarily just made of the private variables currency, price and vehicleId.
PriceRepository
This repository provide a type of data persistence while the web service runs, namely the ID->price pairing generated by the PricingService
.
pricing.service
PriceException
This creates a PriceException
that can be thrown when an issue arises in the PricingService
.
PricingService
The Pricing Service does most of the legwork of the code. Here, it creates a mapping of random prices to IDs, as well as the method (in our mock service here) to generate the random prices. Once converted to a microservice, the Service should not be explicitly necessary.